<% subscribe events_path(channels: ["stack.#{@stack.id}"]), '#layout-content' %>

<%= render partial: 'shipit/stacks/header', locals: {stack: @stack} %>
<%= render partial: 'shipit/stacks/banners', locals: {stack: @stack} %>

<div class="wrapper">
  <section>
    <header class="section-header">
      <h2>Undeployed Commits</h2>

      <div class="commit-list-actions">
        <% if params[:force] %>
          <%= link_to t('emergency_mode.disable'), stack_path(@stack) %>
        <% else %>
          <%= link_to t('emergency_mode.enable'), stack_path(@stack, force: 1, noredirect: 1), title: t('emergency_mode.enable_description') %>
        <% end %>
      </div>
    </header>
    <ul class="commit-list">
      <%= render partial: 'shipit/commits/commit', collection: @undeployed_commits %>
    </ul>
  </section>

  <section>
    <header class="section-header">
      <h2>Currently Deploying Commits</h2>
    </header>
    <ul class="commit-list">
      <%= render partial: 'shipit/commits/commit', collection: @active_commits %>
    </ul>
  </section>

  <% cache [@stack, params[:force]] do %>
    <section>
      <header class="section-header">
        <h2>Previous Deploys</h2>
      </header>
      <ul class="commit-list">
        <%= render partial: 'shipit/tasks/task', collection: @tasks %>
      </ul>
    </section>
  <% end %>
</div>
